import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/*
反序列化：

 */
public class ObjectInputStreamTest01 {
    public static void main(String[] args) {
        try {
            ObjectInputStream ois = new ObjectInputStream(new FileInputStream("C:\\Users\\30539\\Desktop\\text2.txt"));
            Object obj = ois.readObject();
            //返回的是一个Student对象，这里会调用Student类的toString方法，该方法需要被重写。
            System.out.println(obj);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
}
